package com.longxi.tianjintianbao.ui.activity.approval;

import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.approval.ApprovalSaveAtPresenter;
import com.longxi.tianjintianbao.ui.view.approval.IApprovalSaveAtView;

import butterknife.BindView;

/**
 * Created by cxw on & 2018/12/13
 */
public class ApprovalSaveActivity extends BaseActivity<IApprovalSaveAtView, ApprovalSaveAtPresenter> implements IApprovalSaveAtView {

    @BindView(R.id.radioGroup)
    RadioGroup mRadioGroup;
    @BindView(R.id.llNextNode)
    LinearLayout mLlNextNode;
    @BindView(R.id.tvNextNodeName)
    TextView mTvNextNodeName;
    @BindView(R.id.tvNextNodeCheckerName)
    TextView mTvNextNodeCheckerName;
    @BindView(R.id.llRejectNode)
    LinearLayout mLlRejectNode;
    @BindView(R.id.radioGroupRejectNode)
    RadioGroup mRadioGroupRejectNode;
    @BindView(R.id.etContent)
    EditText mEtContent;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_approval_save;
    }

    @Override
    protected ApprovalSaveAtPresenter createPresenter() {
        return new ApprovalSaveAtPresenter(this);
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
    }

    @Override
    public void initListener() {
        super.initListener();
        mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(checkedId == R.id.rBtnNormal){
                    mPresenter.check = mPresenter.CHECK_PASS;
                }else{
                    mPresenter.check = mPresenter.CHECK_NO_PASS;
                }
                mPresenter.showUI();
            }
        });

        mRadioGroupRejectNode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(checkedId == R.id.rBtnAStep){
                    mPresenter.rejectnode = mPresenter.REJECTNODE_A_STEP;
                }else{
                    mPresenter.rejectnode = mPresenter.REJECTNODE_ORIGINATOR;
                }
            }
        });

        mTvNextNodeName.setOnClickListener(v -> mPresenter.showNextNodes());
        mTvNextNodeCheckerName.setOnClickListener(v -> mPresenter.showNextNodeCheckers());
        mTvRight.setOnClickListener(v -> mPresenter.myApprovalSave());
    }

    @Override
    public RadioGroup getRadioGroup() {
        return mRadioGroup;
    }

    @Override
    public LinearLayout getLlNextNode() {
        return mLlNextNode;
    }

    @Override
    public TextView getTvNextNodeName() {
        return mTvNextNodeName;
    }

    @Override
    public TextView getTvNextNodeCheckerName() {
        return mTvNextNodeCheckerName;
    }

    @Override
    public LinearLayout getLlRejectNode() {
        return mLlRejectNode;
    }

    @Override
    public RadioGroup getRadioGroupRejectNode() {
        return mRadioGroupRejectNode;
    }

    @Override
    public EditText getEtContent() {
        return mEtContent;
    }
}
